	import com.AppConfing;
	import com.data.BaseUIData;
	import com.events.SSJEvent;
	import com.events.SSJEventInit;
	import com.managers.AssetLoadManager;
	import com.managers.MouseManager;
	import com.managers.StageManager;
	
	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.geom.Rectangle;
	
	import mx.collections.XMLListCollection;
	import mx.controls.List;
	import mx.core.UIComponent;
	import mx.events.FlexEvent;
	import mx.events.MenuEvent;
	import mx.events.ResizeEvent;
	
	import spark.components.List;
	
	private function init() : void
	{
		//设置menubar数据
		var menubarXML:XMLList =
			<>
				<menuitem label="文件" data="file">
					<menuitem label="打开" data="open"/>
					<menuitem label="导出" data="export"/>
				</menuitem>
			</>;
		var menuBarCollection:XMLListCollection = new XMLListCollection(menubarXML);
		titleMenubar.labelField = "@label";
		titleMenubar.dataProvider = menuBarCollection;
		titleMenubar.addEventListener(MenuEvent.ITEM_CLICK,menubarClick);
	}
	
	private function _addStage() : void
	{
		AppConfing.Init();
		MouseManager.Init(rect,this.stage);
		BaseUIData.Init(this);
		StageManager.Init(ConComponent);
		compoentInit();
		
		this.stage.addEventListener(SSJEventInit.RECIVE_HAND,onRecivehand);
	}
	
	private function menubarClick(event : MenuEvent) : void
	{
		trace("event.item.data :", event.item.@data);
		
	}

	protected function baseList_downHandler(event:MouseEvent):void
	{
		// TODO Auto-generated method stub
		trace("点击了：",baseList.selectedItem.name);
		MouseManager.Hand(baseList.selectedItem,AppConfing.TYPE_BASEUI);
	}

//根据panel的大小画一个矩形的区域用于检测鼠标事件。--------------------
	private var rect : Rectangle;
	protected function panel1_resizeHandler(event:ResizeEvent):void
	{
		// TODO Auto-generated method stub
		rect = new Rectangle(panelcon.x, panelcon.y+60, panelcon.width, panelcon.height-40);
		MouseManager.updatarect = rect;
	}

	protected function panelcon_creationCompleteHandler(event:FlexEvent):void
	{
		// TODO Auto-generated method stub
		rect = new Rectangle(panelcon.x, panelcon.y+60, panelcon.width, panelcon.height-40);
		MouseManager.updatarect = rect;
	}

//资源加载显示进度------------------------------------------
	private var shape : UIComponent;
	protected function maskgroup_creationCompleteHandler(event:FlexEvent):void
	{
		// TODO Auto-generated method stub
		shape = new UIComponent();
		shape.graphics.beginFill(0x363636,0.5);
		shape.graphics.drawRect(0,0,maskgroup.width,maskgroup.height);
		shape.graphics.endFill();
		maskgroup.addElementAt(shape,0);
		loadprogressBar.x = (maskgroup.width - loadprogressBar.width) * 0.5;
		loadprogressBar.y = (maskgroup.height - loadprogressBar.height) * 0.5;
	}
	
	protected function maskgroup_resizeHandler(event:ResizeEvent):void
	{
		// TODO Auto-generated method stub
		if(shape == null)return;
		shape.graphics.clear();
		shape.graphics.beginFill(0x363636,0.5);
		shape.graphics.drawRect(0,0,maskgroup.width,maskgroup.height);
		shape.graphics.endFill();
		loadprogressBar.x = (maskgroup.width - loadprogressBar.width) * 0.5;
		loadprogressBar.y = (maskgroup.height - loadprogressBar.height) * 0.5;
	}
//----------------------------------------------------------
	/**
	 * 接收鼠标松开后有处理加入显示列表操作
	 * @param event
	 * 
	 */
	private function onRecivehand(event : SSJEvent) : void
	{
		trace("ssjeventdata : ",event.eventData);
		StageManager.addChild(event.eventData);
	}

	private function compoentInit() : void
	{
		[Embed(source="assets/uisource/Button.jpg")]
		var buttonClass : Class;
		var buttonIcon : Bitmap = new buttonClass;
		
		[Embed(source="assets/uisource/UIFrame.jpg")]
		var frameClass : Class;
		var frameIcon : Bitmap = new frameClass;
		
		[Embed(source="assets/uisource/ComboBox.jpg")]
		var comboBoxClass : Class;
		var comboBoxIcon : Bitmap = new comboBoxClass;
		
		[Embed(source="assets/uisource/DataGrid.jpg")]
		var dataGridClass : Class;
		var dataGridIcon : Bitmap = new dataGridClass;
		
		[Embed(source="assets/uisource/List.jpg")]
		var listClass : Class;
		var listIcon : Bitmap = new listClass;
		
		[Embed(source="assets/uisource/Label.jpg")]
		var labelClass : Class;
		var labelIcon : Bitmap = new labelClass;
		
		var listArr : Array = new Array;
		listArr.push({name : "Button",icondata : buttonIcon, icon : buttonClass});
		listArr.push({name : "Scale9Image",icondata : frameIcon, icon : frameClass});
		listArr.push({name : "ComboBox",icondata : comboBoxIcon, icon : comboBoxClass});
		listArr.push({name : "DataGrid",icondata : dataGridIcon, icon : dataGridClass});
		listArr.push({name : "List",icondata : listIcon, icon : listClass});
		listArr.push({name : "Label",icondata : labelIcon, icon : labelClass});
		
		baseList.dataProvider = listArr;
	}